package com.gezi.admin.module.code.gentable.table.model;

import com.gezi.admin.config.validate.constraint.enumvalid.EnumValid;
import com.gezi.admin.config.validate.constraint.dict.ValidDictEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;
import java.util.Map;

/**
 * @Author 格子代码
 * @createDate 2024/2/10 09:00
 * @contact 1424529270@qq.com
 */
@Data
public class CodeGenTableAddParamModel {

    @NotBlank(message = "名称不能为空")
    @Size(min = 1,max = 10,message = "名称长度不正确")
    @ApiModelProperty(value = "名称")
    private String name;

    @NotNull(message = "年龄不能为空")
    @Min(value = 20,message = "年龄最小为20")
    @Max(value = 100,message = "年龄最大为100")
    @ApiModelProperty(value = "年龄")
    private Integer age;

    @NotNull(message = "生日不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "生日")
    private Date birthday;

    @NotNull(message = "是否vip不能为空")
    @ApiModelProperty(value = "是否vip")
    private Boolean isVip;

    /**
     * 正则表达式
     */
    @NotBlank(message = "状态不能为空")
    @Pattern(regexp = "^[0|1]*$",message = "状态值不符合规定") //正则表达式。只能String类型
    @ApiModelProperty(value = "状态。1:正常；0:异常")
    private String state;

    /**
     * 枚举。
     */
    @EnumValid(target = CodeGenTableEnum.class, message = "状态值不符合规定")
    @ApiModelProperty(value = "状态")
    private String state2;

    /**
     * 字典
     */
    @ValidDictEnum(type = "sex",message = "性别值不符合规定")
    @ApiModelProperty(value = "性别")
    private String sex;

    /** 请求参数 */
    @ApiModelProperty(value = "params")
    private Map<String, Object> params;
}